// GLGraphicsScene.h
// 
#ifndef GLGRAPHICSSCENE_ONCE
#define GLGRAPHICSSCENE_ONCE

#include <QGraphicsScene>

#include "MouseStatus.h"
#include "Settings.h"

class QGraphicsSceneMouseEvent;
class QGraphicsSceneWheelEvent;
class QGraphicsSceneContextMenuEvent;

namespace OpenGL{
	class Renderer;
}

namespace QtFwk{

class GLGraphicsView;
class UserInteractionManager;

class GLGraphicsScene : public QGraphicsScene
{
	Q_OBJECT


protected:
	UserInteractionManager *uim;
	OpenGL::Renderer	   *renderer;
	QWidget				   *view;

	Settings::ZoomMode    zoomMode;
	bool				  updating;
	QPointF				  currentWorldPoint;
	QPointF				  currentPixelPoint;

	void trackMousePosition( const QPointF &mousePosition );

	virtual void mousePressEvent       ( QGraphicsSceneMouseEvent *e );
	virtual void mouseMoveEvent        ( QGraphicsSceneMouseEvent *e );
	virtual void mouseReleaseEvent     ( QGraphicsSceneMouseEvent *e );
	virtual void wheelEvent            ( QGraphicsSceneWheelEvent *e );
	virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *e );
	virtual void contextMenuEvent      ( QGraphicsSceneContextMenuEvent *e);
	virtual void keyPressEvent		   ( QKeyEvent *e );
	virtual void keyReleaseEvent	   ( QKeyEvent *e );

public:
	GLGraphicsScene( QWidget *parent );
	virtual ~GLGraphicsScene();

	virtual void postInitialization() {}
	virtual void drawBackground(QPainter *painter, const QRectF &rect) = 0;
	virtual void makeCurrent();

	virtual void setZoomMode( Settings::ZoomMode zm );
	//virtual void setZoomInterval( double minValue, double maxValue );
	//virtual bool isUpdating() const;
// ================================================================================================
//                                              QT
// ================================================================================================

	virtual void onMouseMoved();
	virtual void onMousePressed();
	virtual void onMouseReleased();
	virtual void onMouseWheel();
	virtual void onMouseDoubleClick();

	virtual void translateScene();
	virtual void zoomScene();
	virtual void resizeScene( int w, int h );
	virtual void updateDrawables();

private slots:
	void onResize( const QRectF &r );
// ================================================================================================
//                                              QT
// ================================================================================================
};


}


#endif